-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix Popover Nested Scrolling #365
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple questions. More for my own learning.
const hidePopoverWhenOutOfView = ( | ||
entries: IntersectionObserverEntry[] | ||
): void => { | ||
if (!entries.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit-picky, but I think this function could be simplified to be
if (!!entries.length && entries[0].isIntersecting === false ) {
onHide()
}
useLayoutEffect((): (() => void) => { | ||
handleUpdateStyles() | ||
window.addEventListener('scroll', handleUpdateStyles) | ||
observer.observe(triggerRef.current) | ||
window.addEventListener('scroll', handleUpdateStyles, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the true
do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a whole day to figure out, but scroll
events do not bubble by default. Adding this third argument in forces them to bubble
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment explaining that?
window.addEventListener('resize', handleUpdateStyles) | ||
|
||
return (): void => { | ||
observer.disconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not be necessary, but I threw it in there so the observer stops observing as a sort of "cleanup"
Closes #364
Changes
PopoverDialog
uses to maintain position to allow event bubblingPopover
combined withDapperScrollbars
IntersectionObserver
to hidePopover
when its trigger scrolls out of viewScreenshots
Checklist
Check all that apply